---
layout: "default"
title: "AnyIndex"
description: "Swift documentation for 'AnyIndex': A wrapper over an underlying index that hides the specific underlying type."
keywords: "AnyIndex,struct,swift,documentation,<,=="
root: "/v3.1"
---

<div class="intro-declaration"><code class="language-swift">struct AnyIndex</code></div>

<div class="discussion comment">
    <p>A wrapper over an underlying index that hides the specific underlying type.</p>

<p><strong>See Also:</strong> <code>AnyCollection</code></p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">Comparable, Equatable</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>



<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_">init(<wbr>_:)</a><div class="comment collapse" id="comment-init_"><div class="p">
    <p>Creates a new index wrapping <code>base</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;BaseIndex where BaseIndex : Comparable&gt;(_ base: BaseIndex)</code>

    </div></div>
</div>





<h3>Instance Methods</h3>
<div class="declaration" id="func-lt_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-lt_rhs_">func &lt;(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-lt_rhs_"><div class="p">
    <p>Returns a Boolean value indicating whether the first argument represents a
position before the second argument.</p>

<p>The types of the two underlying indices must be identical.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An index to compare.
  <strong>rhs:</strong> Another index to compare.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &lt;(lhs: AnyIndex, rhs: AnyIndex) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-eqeq_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-eqeq_rhs_">func ==(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-eqeq_rhs_"><div class="p">
    <p>Returns a Boolean value indicating whether two indices wrap equal
underlying indices.</p>

<p>The types of the two underlying indices must be identical.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An index to compare.
  <strong>rhs:</strong> Another index to compare.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func ==(lhs: AnyIndex, rhs: AnyIndex) -&gt; Bool</code>
    
    
</div></div>
</div>


